<template>
  <div id="app">
    <router-view />
  </div>
</template>
<script>
  import { getStatus} from "./utils/getStatus";
  export default {
    created() {
      //获取登录状态
      getStatus().then(res=>{
        //如果是登录成功状态
        if(res.data.code==0){
          // console.log(res);
          //设置用户基本信息
          this.$store.commit("loginStatus",true)
          this.$store.commit("login",{
            nickname:res.data.userInfo.nickname,
            portrait:res.data.userInfo.avatarUrl
          })
        }else {
          //登录失败
          // console.log(1)
          this.$store.commit("login",{})
          this.$store.push("/")
          this.$store.commit("change",true)
        }
      })
    }
  }
</script>
<style lang="less">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

#nav {
  padding: 30px;

  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
</style>
